<?php get_header(); ?>

	<div id="content-wrap"><div id="content">

	<div id="sidebar" >
<?php
if ( !is_user_logged_in() ) {
?>
<div id="log">
<form name="loginform" id="loginform" action="http://bloggles.info/wp-login.php" method="post">
<h1>Blogger?</h1>
<p><label>Username<br /><input type="text" name="log" id="user_login" value="" tabindex="1" /></label></p>
<p><label>Password<br /><input type="password" name="pwd" id="user_pass" value="" tabindex="2" /></label></p>

<p class="rememberme"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />Remember me<a href="http://faqs.bloggles.info/2008/03/22/what-is-remember-me-login/" title="what is this?">?</a></label></p>
<input type="hidden" id="redirect_to" name="redirect_to" value="http://www.bloggles.info" />
<input type="hidden" id="testcookie" name="testcookie" value="0" />
<p class="submit"><input type="submit" name="submit" id="login-form" value="Login" tabindex="4" /></p>
<p class="lost"><a href="http://bloggles.info/wp-login.php?action=lostpassword">Lost your password?</a><br /><a rel="nofollow" href="http://bloggles.info/signup/?ref=wpbutton">Get a free blog!</a></p>
</div>
</form>
<?php } ?>
<script type="text/javascript">document.cookie='TESTCOOKIE=home; expires=<?php $exp = 432000 + time(); echo date(("D, d-M-Y H:i:s"), $exp) . ' GMT'; ?>; path=/';document.getElementById('testcookie').value='1'</script>
<?php
$recentPosts = new WP_Query();
$recentPosts->query('showposts=5');

//query_posts( 'showposts=8' );

	if ( have_posts() ) : ?>
	<h1>What's news?</h1><ul>
		<?php //while ( have_posts() ) : the_post(); ?>
		<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
		<li><a href="<?php the_permalink() ?>" rel="noffolow" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title();?></a></li>
		<?php endwhile; ?>
	</ul>
	<?php endif;
?>

<br />
<div style="padding:10px;">
	<script type="text/javascript">
	<!--
		google_ad_client = "pub-0756599696445030";
		google_ad_width = 160;
		google_ad_height = 600;
		google_ad_format = "160x600_as";
		google_ad_type = "text_image";
		google_color_border = "ffffff";
		google_color_bg = "ffffff";
		google_color_link = "006699";
		google_color_url = "006699";
		google_color_text = "808080";;
	//--></script>
	<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div>
</div>
<!--Sidebar End-->
		<div id="main">
<?php
if ( is_user_logged_in() ){
	echo'<h3>Welcome! ' . $current_user->user_login .'</h3><p>You can use the links in the <strong>green bar</strong> at the top of your screen to get to your blog dashboard.</p>';
	$image_path = get_bloginfo( 'wpurl' )."/avatars/";
	$the_avatar = $image_path.$current_user->ID. ".jpg?" .time();
	if ( file_exists("$avatars_path/$current_user->ID.jpg") ){
		echo '<div style="float:right;margin-top:0;"><img title="'.$current_user->user_login.'" style="margin: 2px; padding: 2px;border: solid 1px #999; width:72px;" src="' . $the_avatar. '" alt="' . $current_user->user_login . '"  /></div>';
	} else {
		//echo '<div style="float:right;margin-top:0;"><a href="http://' . $current_user->user_login . '.bloggles.info/wp-admin/profile.php"><img title="'.$current_user->user_login.'" style="margin: 2px; padding: 2px;border: solid 1px #999;" src="' . $image_path . 'default.jpg" alt="You may upload your photo in your admin panel." /></a></div>';
		echo '<div style="float:right;margin-top:0;">' .get_avatar( $current_user->ID, $current_user->user_email, 16 ) .'</div>';
	}
} else {
		echo '<h3>Welcome to Blogates!</h3>';
		echo '<span style="float:right;padding:3px;"><a title="get a free personal weblog." href="http://bloggles.info/signup/?ref=index"><img src="http://bloggles.info/wp-content/themes/home/images/butt.png" border="0" /></a><br /><a href="http://donate.wvus.org/OA_HTML/xxwvibeCZzpEntry.jsp?go=sponsor&site=WVDONATIONS&respid=22372&language=US"><img src="http://bloggles.info/wp-admin/images/18060_234x60.gif" border="0" alt="Become a child sponsor today."></a></span><p>Blogates.com is free builds your site, organizes and archives your posts, and publishes your thought, journal with no experience in HTML, FTP, or graphic design. You may publish written text, photos, journal, thought, and more with just a single click of your mouse.</p>';
}
?>
<p>

<?php 

if ( is_user_logged_in() ) {
	//echo "<p><h3>Welcome! " . $current_user->user_login ."</h3></p>";
	$blogs = get_blogs_of_user( $current_user->ID );

	if ( ! empty($blogs) ) echo '<p>Here are the blogs you already have:</p><ul>'; foreach ( $blogs as $blog ) {
		echo "<li><a href='http://" . $blog->domain . $blog->path . "' title='Visit blog'>" . $blog->blogname . "</a> (<a href='http://" . $blog->domain . $blog->path . "wp-admin/' title='Login to dashboard'>Dashboard</a>)</li>";
	}
	echo "<li><a href='/signup/?ref=registered'>Register another blog &raquo;</a></li>";
}
	echo '</ul>';
?>

<div id="news">
<h1>LATEST</h1>

<?php
require_once (ABSPATH . WPINC . '/rss.php');

	$rss = @fetch_rss('http://tags.bloggles.info/feed/');
	if ( isset($rss->items) && 0 != count($rss->items) ) {
		?>
		<?php
		$rss->items = array_slice($rss->items, 0, 6);
		foreach ($rss->items as $item ) {
			?>
			<div id="latest" class="post" id="post">
			<p><strong><a rel='nofollow' href='<?php echo wp_filter_kses($item['link']); ?>' title='<?php echo wp_specialchars($item['title']); ?>'><?php echo wp_specialchars($item['title']); ?></a></strong></p>
			<p><?php echo wp_specialchars($item['description']); ?></p>
			</div>
			<?php
		}
	}
?>
</p>
</div>

<h1>UPDATED</h1>
<div id="news">
<?php
$blogs = get_last_updated();
if( is_array( $blogs ) ) {
	echo '<ul>';
	foreach( $blogs as $details ) {
		?><li><a href="http://<?php echo $details[ 'domain' ] . $details[ 'path' ] ?>" rel="nofollow" title="<?php echo get_blog_option( $details[ 'blog_id' ], 'blogname' ) ?>"><?php echo get_blog_option( $details[ 'blog_id' ], 'blogname' ) ?></a></li><?php
	}
	echo '</ul>';
}
?>

<?php //the_mutags(); ?>

</div>

</div>
<div style="width:160px;text-align:justify;">
<h1>Tags<h1>
<?php mu_tag_cloud($custom = array(
			'maxsize' => '120',
			'minsize' => '60',
			'limit' => '20',
			'orderby' => 'wd',
			)); ?>
</div>
		</div>

	<!-- content-wrap ends here -->
	</div></div>
<?php get_footer(); ?>